package cn.pconline.autoclub.web.app;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.pconline.autoclub.entity.Activity;
import cn.pconline.autoclub.entity.ActivityMember;
import cn.pconline.autoclub.entity.ActivityPic;
import cn.pconline.autoclub.entity.ActivityPlace;
import cn.pconline.autoclub.entity.Club;
import cn.pconline.autoclub.entity.ClubMember;
import cn.pconline.autoclub.entity.DynaInfo;
import cn.pconline.autoclub.entity.User;
import cn.pconline.autoclub.service.ActivityPicService;
import cn.pconline.autoclub.service.ActivityPlaceService;
import cn.pconline.autoclub.service.ActivityService;
import cn.pconline.autoclub.service.ClubService;
import cn.pconline.autoclub.service.DynaIndexService;
import cn.pconline.autoclub.service.DynaService;
import cn.pconline.autoclub.service.IntfService;
import cn.pconline.autoclub.service.MemberService;
import cn.pconline.autoclub.service.MessageService;
import cn.pconline.autoclub.service.UserService;
import cn.pconline.autoclub.util.DateUtils;
import cn.pconline.autoclub.util.EncodeUtils;
import cn.pconline.autoclub.util.Pager;
import cn.pconline.autoclub.util.Regex;
import cn.pconline.autoclub.util.ValidateUtils;
import cn.pconline.autoclub.util.WebUtils;
import cn.pconline.autoclub.util.app.AppControllerStatic;
import cn.pconline.autoclub.util.dyna.AbstractDyna;
import cn.pconline.autoclub.web.UserAuth;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;

/**
 * @author zhouruxuan
 * @date 2015年1月30日 上午10:24:11
 */

@Controller
@RequestMapping(value = "/appapi")
public class AppActivityController {

    @Autowired
    private ClubService clubService;
    @Autowired
    private ActivityService activityService;
    @Autowired
    private UserService userService;
    @Autowired
	private ActivityPlaceService activityPlaceService;
	@Autowired
	private ActivityPicService activityPicService;
	@Autowired
	private UserAuth userAuth;
	@Autowired
	private MemberService memberService;
    @Autowired
    private MessageService messageService;
    @Autowired
    private DynaService dynaService;
    @Autowired
    private IntfService intfService;
    @Autowired
    private DynaIndexService dynaIndexService;
    
    //活动创建默认封面图
    private static final String defalutImg = "http://www1.pcauto.com.cn/bbs/cargroup/2014/images/defaultphoto8.jpg";
	private static final Logger log = LoggerFactory.getLogger(AppActivityController.class);
    /**是否报名：未报名**/
    private static final int STATUS_NO_SIGNUP = 2; 

    /**批量数据最大数**/
    private static final int BATCH_MAX_SIZE = 100;
    /**
     *  发布活动
     *
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value = "/1.0/activity/editActivity.do", method = RequestMethod.POST)
    public void editActivity(HttpServletRequest req, HttpServletResponse resp) {
    	    WebUtils.setEncoding4App(req, resp);
    	    //获取相关参数
            String callback = AppControllerStatic.paramCallback(req);
      	   //获取用户信息
            User user = userAuth.getUser(req, resp);
            JSONObject json = new JSONObject();
            //判断用户是否登录
            if (user == null || user.getUid() <= 0) {
                AppControllerStatic.printErrorMsg(resp, "用户未登录", json, callback, AppControllerStatic.V1_VERSION_LATEST);
                return;
            }
            
            ClubMember clubMember = memberService.findClubMemberByUserId(user.getUid());
            //检查是否加入车友会
            if(clubMember == null) {
            	AppControllerStatic.printErrorMsg(resp, "你还没加入车友会，请先加入车友会", json, callback, AppControllerStatic.V1_VERSION_LATEST);
            	return;
            }
         
            //获得车友会信息
            Club club = clubService.getValidClub(clubMember.getClubId());
            if(club == null){
            	AppControllerStatic.printErrorMsg(resp, "你还没加车友会", json, callback, AppControllerStatic.V1_VERSION_LATEST);
            	return;
            }
            
            Activity activity = this.convertActivity(req); 
            long activityId = activity.getActivityId();
            
            if(activityId > 0){	//如果是修改活动，先判断该用户是否可以修改
            	Activity oldActivity = activityService.findById(activityId);
            	if(oldActivity==null){
            		AppControllerStatic.printErrorMsg(resp, "该活动不存在", json, callback, AppControllerStatic.V1_VERSION_LATEST);
            		return;
            	}
            	if(user.getUid()!=oldActivity.getCreateBy()){	//创建活动不是该用户
            		AppControllerStatic.printErrorMsg(resp, "没有权限修改", json, callback, AppControllerStatic.V1_VERSION_LATEST);
            		return;
            	}
            	if(club.getClubId()!=oldActivity.getClubId()){	//活动所在车友会与用户车友会不对应（防止用户退出车友会再进行修改活动）
            		AppControllerStatic.printErrorMsg(resp, "您不在该车友会", json, callback, AppControllerStatic.V1_VERSION_LATEST);
            		return;
            	}
            	activity.setCreateAt(oldActivity.getCreateAt());
            	activity.setLongContext(oldActivity.getLongContext());
            }

            //表单验证
            String checkActivityMsg = this.checkActivity(activity);
            if (!checkActivityMsg.isEmpty()) {
            	AppControllerStatic.printErrorMsg(resp, checkActivityMsg, json, callback, AppControllerStatic.V1_VERSION_LATEST);
                return;
            }
            
            //手机号码验证
            String phone = WebUtils.param(req, "authorTel", "");
            String checkPhoneResult = ValidateUtils.checkPhone(phone);
            if(StringUtils.isNotBlank(checkPhoneResult)) {
            	AppControllerStatic.printErrorMsg(resp, checkPhoneResult, json, callback, AppControllerStatic.V1_VERSION_LATEST);
                return;
            }
            
            
            //重新赋值
            activity.setClubId(club.getClubId());
            activity.setCreateBy(user.getUid());
            
            
            //获得活动图片集合
            List<ActivityPic> activityPics = this.convertActivityPics(req);
            if (activityPics == null) {
            	AppControllerStatic.printErrorMsg(resp, "图片内容格式不正确", json, callback, AppControllerStatic.V1_VERSION_LATEST);
                return;
            }
            
            //获得活动集合地点，线上活动不用填写集合地
            List<ActivityPlace> gatherings = this.convertActivityPlace(req,ActivityPlace.TYPE_GATHERING);
            if(activity.getType() != Activity.TYPE_OTHER) {
            	if (gatherings == null || gatherings.size () <= 0) {
                	AppControllerStatic.printErrorMsg(resp, "请输入集合地点", json, callback, AppControllerStatic.V1_VERSION_LATEST);
                    return;
                }
            }else {//线上活动不保存集合地点
            	gatherings = new ArrayList<ActivityPlace>();
            }
            
            //经纬度范围判断
            for(ActivityPlace activityPlace : gatherings) {
            	double lon = activityPlace.getLongitude();
            	double lat = activityPlace.getLatitude();
            	if (lon > 135 || lon < 73) {
            		AppControllerStatic.printErrorMsg(resp, "集合地点经度范围（73-135)", json, callback, AppControllerStatic.V1_VERSION_LATEST);
                    return;
                }
                if (lat > 53 || lat < 3) {
                	AppControllerStatic.printErrorMsg(resp, "集合地点纬度范围（3-53)", json, callback, AppControllerStatic.V1_VERSION_LATEST);
                    return;
                }
            }
            
            //获取目的地点
            List<ActivityPlace> destinations = this.convertActivityPlace(req,ActivityPlace.TYPE_DESTINATION);
            if(activity.getType()==Activity.TYPE_DRIVING){ //自驾游判断必须有一个目的地
            	if(destinations== null || destinations.size()<=0){
                  	AppControllerStatic.printErrorMsg(resp, "自驾游必须有一个目的地", json, callback, AppControllerStatic.V1_VERSION_LATEST);
                    return;
            	}
            } else {//非自驾游活动不保存目的地点
            	destinations = new ArrayList<ActivityPlace>();
            }
            
            if(destinations.size() > 8) {
            	AppControllerStatic.printErrorMsg(resp, "最多可填写8个目的地点", json, callback, AppControllerStatic.V1_VERSION_LATEST);
                return;
            }
            
            
            //经纬度范围判断
            for(ActivityPlace activityPlace : destinations) {
            	double lon = activityPlace.getLongitude();
            	double lat = activityPlace.getLatitude();
            	if (lon > 135 || lon < 73) {
            		AppControllerStatic.printErrorMsg(resp, "目的地点经度范围（73-135)", json, callback, AppControllerStatic.V1_VERSION_LATEST);
                    return;
                }
                if (lat > 53 || lat < 3) {
                	AppControllerStatic.printErrorMsg(resp, "目的地点纬度范围（3-53)", json, callback, AppControllerStatic.V1_VERSION_LATEST);
                    return;
                }
            	
            }
            
            gatherings.addAll(destinations);
            List<ActivityPlace> activityPlaces = gatherings;
            if(activityPlaces.size()>0){
                ActivityPlace whoisPlace = activityPlaces.get(activityPlaces.size()-1);	//取最后一个作为活动地址（优先取最后一个目的地，没有目的地取集合地点）
                double longitude = whoisPlace.getLongitude();
                double latitude = whoisPlace.getLatitude();
                JSONObject areaObject = intfService.getPlaceByLngLli(longitude, latitude);
        		if(areaObject!=null){
        			try {
        				String provinceName = areaObject.getString("pro");
            			long provinceId = areaObject.getLong("proCode");
            			String cityName = areaObject.getString("city");
            			long cityId = areaObject.getLong("cityCode");
            			activity.setProvinceId(provinceId);
            			activity.setProvinceName(provinceName);
            			activity.setCityId(cityId);
            			activity.setCityName(cityName);
        			} catch(NullPointerException exception) {
        				log.error("app create Activity : call whois throw Exception, longitude:{}, latitude:{}", longitude,latitude, exception);
        			}
            	}
            }

            if (activityId > 0) {
                    //update
                    activityService.updateActivity(activity);
                    if(!activityPics.isEmpty()){
                    	if(activityPics.size() > 50) {
                    		AppControllerStatic.printErrorMsg(resp, "最多可上传50张照片", json, callback, AppControllerStatic.V1_VERSION_LATEST);
                        	return;
                    	}
                    }
                    
                    //修改图片
                    int resultPic = activityPicService.deleteAndAddActivityPic(activityId, activityPics);
                	if(resultPic <= 0 && !activityPics.isEmpty()){
                		AppControllerStatic.printErrorMsg(resp, "操作失败", json, callback, AppControllerStatic.V1_VERSION_LATEST);
                    	return;
                	}
                	
                	//修改活动地点
                	long resultPlace = activityPlaceService.deleteAndAddActivityPlace(activityId, activityPlaces);
                	if(resultPlace <= 0 && !activityPlaces.isEmpty()){
                		AppControllerStatic.printErrorMsg(resp, "操作失败", json, callback, AppControllerStatic.V1_VERSION_LATEST);
                    	return;
                	}
              } else {
                    //add
                  	activity.setCreateAt(DateUtils.getNow());
                  	activity.setCreateBy(user.getUid());
                    activity.setStatus(Activity.STATUS_YES);
                    activityId =  activityService.createActivity(activity);
                    if(!activityPics.isEmpty()){
                    	int result = activityPicService.batchCreateActivityPic(activityId, activityPics);
                    	if(result <= 0){
                    		AppControllerStatic.printErrorMsg(resp, "操作失败", json, callback, AppControllerStatic.V1_VERSION_LATEST);
                        	return;
                    	}
                    }
                    if(!activityPlaces.isEmpty()){
                    	int result = activityPlaceService.batchCreateActivityPlace(activityId, activityPlaces);
                    	if(result <= 0){
                    		AppControllerStatic.printErrorMsg(resp, "操作失败", json, callback, AppControllerStatic.V1_VERSION_LATEST);
                        	return;
                    	}
                    }
                    if (activityId > 0) {
                        // 发起活动发消息通知全体会员
                        List<ClubMember> members = memberService.listMemberByClubId(activity.getClubId());
                        for (ClubMember u : members) {
                            if(u.getUid() != user.getUid()) {
                                messageService.send(u.getUser(), MessageService.NEW_ACTIVITY,
                                           messageService.assembleUserUrl(user.getUid(), user.getNickname()), messageService.assembleActivityUrl(club.getClubUrl(), activityId, activity.getTitle()));
                            }
                        }
                        //发布活动动态
                        AbstractDyna dyna = new AbstractDyna();
                        dyna.setClubId(club.getClubId());
                        dyna.setContent(activity.getTitle());
                        dyna.setCreateBy(activity.getCreateBy());
                        dyna.setCreateName(user.getNickname());
                        dyna.setCreateDate(activity.getCreateAt());
                        dyna.setTargetId(activityId);
                        dynaService.createActivityDyna(dyna, null);
                    }
                }
            //更新个人手机号码
            user.setPhone(phone);
            userService.updateUser(user,"phone");
            json.put("activityId", activityId);
            AppControllerStatic.printSuccessMsg(resp, json, callback, AppControllerStatic.V1_VERSION_LATEST);
        }
    
    /**
     * 1.1.36 车友会活动列表接口
     *   1.参数clubId,clubUrl不可以同时为空值；
     *   2.如果参数clubId,clubUrl都传值，以clubId为准进行查找。
     *   
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value = "/1.0/activity/getActivityList.do", method = RequestMethod.GET)
    public void getActivityList(HttpServletRequest request, HttpServletResponse response) {
    	WebUtils.setEncoding4App(request, response);
        long clubId = AppControllerStatic.paramClubId(request);
        String clubUrl = AppControllerStatic.paramClubUrl(request);
        long userId = AppControllerStatic.paramUserId(request);
        String callback = AppControllerStatic.paramCallback(request);
        int pageSize = AppControllerStatic.paramPageSize(request);
        int pageNo = AppControllerStatic.paramPageNo(request);
        int xssEncode = AppControllerStatic.paramXssEncode(request);
        
        JSONObject jsonObject = new JSONObject();
        
        //参数检查
        if(clubId == 0 && StringUtils.isBlank(clubUrl)) {
        	AppControllerStatic.printErrorMsg(response, "参数clubId,clubUrl不可以同时为空值", jsonObject, callback, AppControllerStatic.V1_VERSION);
        	return;
        }
        
        Club club;
        
        //如果两个参数同时存在，以clubId为准
        if(clubId > 0) {
        	club = clubService.getValidClub(clubId);
        } else {
        	club = clubService.getClubByUrl(clubUrl);
        	if(club == null) {
        		AppControllerStatic.printErrorMsg(response, "该车友会域名不存在", jsonObject, callback, AppControllerStatic.V1_VERSION);
            	return;
        	}
        	clubId = club.getClubId();
        }

        if(club == null) {
        	AppControllerStatic.printErrorMsg(response, "该车友会ID不存在", jsonObject, callback, AppControllerStatic.V1_VERSION);
        	return;
        }
        
        //设置返回值
        jsonObject.put("clubId", clubId);
        jsonObject.put("clubUrl", xssEncode == 0 ?
        		club.getClubUrl() : EncodeUtils.encodeForHTMLFilterNull(club.getClubUrl()));
        jsonObject.put("clubName", xssEncode == 0 ? 
        		club.getName() : EncodeUtils.encodeForHTMLFilterNull(club.getName()));
        
        ClubMember member = memberService.findMember(userId, clubId);
        long memberId = 0;
        if (member != null) {
            memberId = member.getId();
        }
        JSONArray jsonAlbum = new JSONArray();
        Pager<Activity> pager = activityService.pageForList(memberId, clubId, false, pageNo, pageSize);
        if (pager != null && !pager.getResultList().isEmpty()) {
            for (Activity activity : pager.getResultList()) {
                JSONObject jsonContent = new JSONObject();
                jsonContent.put("activityId", activity.getActivityId());
                jsonContent.put("title", xssEncode == 0 ? 
                		activity.getTitle() : EncodeUtils.encodeForHTMLFilterNull(activity.getTitle()));
                jsonContent.put("signupDate", activity.getSignupDate().getTime());
                jsonContent.put("beginDate", activity.getBeginDate().getTime());
                jsonContent.put("endDate", activity.getEndDate().getTime());
                jsonContent.put("pic", xssEncode == 0 ?
                		activity.getUrl600x400() : EncodeUtils.encodeForHTMLFilterNull(activity.getUrl600x400()));
                jsonContent.put("limitCount", activity.getMaxJoin());
                Map<String, String> map = activityService.getListActivityStatus(memberId, activity);
                jsonContent.put("statusCode", map.get("code"));
                jsonContent.put("statusMsg", map.get("msg"));
                boolean isSignUp = false; // 是否已经报名
                if (userId > 0) {
                    if (member != null && activityService.isSignUp(activity.getActivityId(), memberId) != null) {
                        isSignUp = true;
                    }
                }
                int activityStatus = getActivityStatus(activity);//活动状态
                jsonContent.put("activityStatus", activityStatus);
                String place;
                if (activity.getOnlineStatus() > 0) {
                    place = "线上";
                } else {
                	String provinceName = activity.getProvinceName() == null ? "" : activity.getProvinceName();
                    String cityName = activity.getCityName() == null ? "" : activity.getCityName();
                    place = provinceName + cityName;
                }
                jsonContent.put("place", xssEncode == 0 ? place : EncodeUtils.encodeForHTMLFilterNull(place));
                jsonContent.put("isSignUp", isSignUp);
                jsonContent.put("applyCount", activity.getJoinNum());
                jsonAlbum.add(jsonContent);
            }
        }
        
        jsonObject.put("data", jsonAlbum);
        AppControllerStatic.printSuccessMsgPager(response, jsonObject, callback, pager, AppControllerStatic.V1_VERSION);
        
    }
    
    /**
     * 获取活动状态 status 0:接受报名，1：报名已截止，2；活动已开始， －1：活动已经结束
     */
    private int getActivityStatus(Activity activity) {
        Date now = DateUtils.getNow();

        if (!now.after(activity.getEndDate())) {//活动还没结束
            if ((now.getTime() <= activity.getSignupDate().getTime())) { //活动未开始 且 报名未结束
                return 0;
            } else if (activity.getSignupDate().getTime() < now.getTime() && activity.getBeginDate().getTime() > now.getTime()) {
                return 1;
            } else {
                return 2;
            }
        } else {
            return -1;
        }
    }
    
    /**	http://rdtrac.pc.com.cn/autoclub/wiki/appapi/4.0
     *   1.3.3 活动列表
     *   1.参数clubId,clubUrl不可以同时为空值；
     *   2.如果参数clubId,clubUrl都传值，以clubId为准进行查找。
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value = "/2.0/activity/getActivityList.do", method = RequestMethod.GET)
    public void getActivityList2(HttpServletRequest request, HttpServletResponse response){
    	WebUtils.setEncoding4App(request, response);
    	long clubId = AppControllerStatic.paramClubId(request);
    	String clubUrl = AppControllerStatic.paramClubUrl(request);
    	String callback = AppControllerStatic.paramCallback(request);
        int pageSize = AppControllerStatic.paramPageSize(request);
        int pageNo = AppControllerStatic.paramPageNo(request);
        int xssEncode = AppControllerStatic.paramXssEncode(request);
        JSONObject jsonObject = new JSONObject();
        
        //参数检查
        if(clubId == 0 && StringUtils.isBlank(clubUrl)) {
        	AppControllerStatic.printErrorMsg(response, "参数clubId,clubUrl不可以同时为空值", jsonObject, callback, AppControllerStatic.V2_VERSION_LATEST);
        	return;
        }
        Club club;
        
        //如果两个参数同时存在，以clubId为准
        if(clubId > 0) {
        	club = clubService.getValidClub(clubId);
        	if(club == null) {
        		AppControllerStatic.printErrorMsg(response, "该车友会不存在", jsonObject, callback, AppControllerStatic.V2_VERSION_LATEST);
            	return;
        	}
        } else {
        	club = clubService.getClubByUrl(clubUrl);
        	if(club == null) {
        		AppControllerStatic.printErrorMsg(response, "该车友会不存在", jsonObject, callback, AppControllerStatic.V2_VERSION_LATEST);
            	return;
        	}
        	clubId = club.getClubId();
        }
        //设置返回值
        jsonObject.put("clubId", clubId);
        jsonObject.put("clubUrl", xssEncode == 0 ? club.getClubUrl() : EncodeUtils.encodeForHTMLFilterNull(club.getClubUrl()));
        jsonObject.put("clubName", xssEncode == 0 ? club.getName() : EncodeUtils.encodeForHTMLFilterNull(club.getName()));
        JSONArray dataArray = new JSONArray();
        Pager<Activity> pager = activityService.pageForList( clubId, false, pageNo, pageSize );
        if (pager != null && !pager.getResultList().isEmpty()){
        	for(Activity activity : pager.getResultList()){
        		JSONObject activityJson = new JSONObject();
        		activityJson.put("activityId", activity.getActivityId());
        		int type = activity.getType();
        		activityJson.put("activityType", type);
        		activityJson.put("title", xssEncode == 0 ? 
                		activity.getTitle() : EncodeUtils.encodeForHTMLFilterNull(activity.getTitle()));
        		activityJson.put("signupDate", activity.getSignupDate().getTime());
        		activityJson.put("beginDate", activity.getBeginDate().getTime());
        		activityJson.put("endDate", activity.getEndDate().getTime());
        		activityJson.put("pic", xssEncode == 0 ?
                		activity.getUrl600x400() : EncodeUtils.encodeForHTMLFilterNull(activity.getUrl600x400()));
        		activityJson.put("limitCount", activity.getMaxJoin());
        		long createBy = activity.getCreateBy();
        		activityJson.put("createBy", createBy);
        		activityJson.put("nickName", xssEncode == 0 ?
        				userService.getNickNameByUserId(createBy): EncodeUtils.encodeForHTMLFilterNull(userService.getNickNameByUserId(createBy)));
        		activityJson.put("activityCost", activity.getMoney());
        		activityJson.put("dayCount", DateUtils.compareDay( activity.getBeginDate(), activity.getEndDate()));
        		
        		String activityPlace = "";
        		if(type == Activity.TYPE_OTHER) {
        			activityPlace = "线上";
        		} else {
        			activityPlace = activity.getCityName() == null ? "" : activity.getCityName() ;
        		}
        		activityJson.put("applyCount", activity.getJoinNum());
        		activityJson.put("activityPlace", xssEncode == 0 ? activityPlace : EncodeUtils.encodeForHTMLFilterNull(activityPlace));
        		dataArray.add(activityJson);
        	}
        }

        jsonObject.put("data", dataArray);
        AppControllerStatic.printSuccessMsgPager(response, jsonObject, callback, pager, AppControllerStatic.V2_VERSION_LATEST);
    }
    
    /**
     * 对象转换
     *
     * @param req
     * @return
     */
    private Activity convertActivity(HttpServletRequest req) {
        Activity activity = new Activity();
        long activityId = WebUtils.paramLong(req, "activityId", 0);
        activity.setActivityId(activityId);
        activity.setType(WebUtils.paramInt(req, "activityType", 0));
        activity.setClubId(WebUtils.paramLong(req, "clubId", 0));
        activity.setTitle(WebUtils.param(req, "title", "").trim());
        activity.setContext(WebUtils.param(req, "content", "").trim());
        activity.setFullContent(WebUtils.param(req, "content", "").trim());  
        activity.setBeginDate(WebUtils.parseDate(req, "beginDate"));
        activity.setEndDate(WebUtils.parseDate(req, "endDate"));
        activity.setSignupDate(WebUtils.parseDate(req, "signupDate"));
        activity.setLongContext(WebUtils.paramInt(req, "longContext", 0));
        activity.setOnlineStatus(WebUtils.paramInt(req, "onlineStatus", 0));
        activity.setProvinceId(WebUtils.paramInt(req, "provinceId", 0));
        activity.setProvinceName(WebUtils.param(req, "provinceName", "").trim());
        activity.setCityId(WebUtils.paramInt(req, "cityId", 0));
        activity.setCityName(WebUtils.getAreaPlaceByReq(req, "cityName", ""));
        activity.setMoney(WebUtils.paramInt(req, "money", 0));
        activity.setPicUrl(WebUtils.param(req, "activityImgUrl", "").trim());
        //修改活动时报名人数不变
        if(activityId > 0) {
        	Activity oldaActivity = activityService.findById(activityId);
        	if(oldaActivity != null) {
        		activity.setJoinNum(oldaActivity.getJoinNum());
        	}
        } else {
        	activity.setJoinNum(WebUtils.paramInt(req, "joinNum", 0));
        }
        activity.setMaxJoin(WebUtils.paramInt(req, "limitCount", 0));
        activity.setCreateBy(WebUtils.paramInt(req, "createBy", 0));
        activity.setStatus(Activity.STATUS_YES);
        return activity;
    }
    
    /**
     * 内容图片转换成List<ActivityPic>
     * @param req
     * @return
     */
    private List<ActivityPic> convertActivityPics(HttpServletRequest req){
  	  String contentImages = WebUtils.param(req, "contentImages", "");
  	  List<ActivityPic> activityPics = new ArrayList<ActivityPic>();
  	  if(!contentImages.isEmpty()){
   		   try {
				JSONArray jsonArray = JSON.parseArray(contentImages);
				int seq = 0;
				for (int i = 0; i < jsonArray.size(); i++) {
					JSONObject jsonObject = (JSONObject) jsonArray.get(i);
					ActivityPic activityPic = new ActivityPic();
					activityPic.setHeight(jsonObject.getIntValue("height"));
					activityPic.setWidth(jsonObject.getIntValue("width"));
					activityPic.setUrl(jsonObject.getString("url"));
					activityPic.setDescription(jsonObject.getString("description"));
					seq++;
					activityPic.setSeq(seq);
					activityPics.add(activityPic);
				}				
		   } catch (JSONException e) {
			  return null;
		   }
   		 
  	  }
  	  return activityPics;
    }
    
   /**
    * 获取集合地点或目的地点
    * @param req
    * @param type
    * @return
    */
  private List<ActivityPlace> convertActivityPlace(HttpServletRequest req,int type){
	  List<ActivityPlace> activityPlaces = new ArrayList<ActivityPlace>();
	  
	  try {
	    if(type == ActivityPlace.TYPE_GATHERING){
	    	  String gatherPlace = WebUtils.param(req, "gatherPlace", "");
	    	  if(!StringUtils.isBlank(gatherPlace)){
	    		  JSONObject jsonObject = JSONObject.parseObject(gatherPlace);
	    	       ActivityPlace activityPlace = new ActivityPlace();
	    	       activityPlace.setLatitude(jsonObject.getDoubleValue("latitude"));
	    	       activityPlace.setLongitude(jsonObject.getDoubleValue("longitude"));
	    	       activityPlace.setName(jsonObject.getString("name"));
	    	       activityPlace.setMarkName(jsonObject.getString("markName"));
	    	       activityPlace.setType(ActivityPlace.TYPE_GATHERING);
	    	       activityPlaces.add(activityPlace);
	    	  }
	      }else if(type==ActivityPlace.TYPE_DESTINATION){
	    	  String destinationPlaces = WebUtils.param(req, "destinationPlaces", "");
	    	  if(!StringUtils.isBlank(destinationPlaces)){
		    	   JSONArray jsonArray = JSON.parseArray(destinationPlaces);
		    	   for(int i=0;i< jsonArray.size(); i++){
		         	 JSONObject jsonObject = (JSONObject) jsonArray.get(i);
		         	 ActivityPlace activityPlace = new ActivityPlace();
		         	 activityPlace.setLatitude(jsonObject.getDoubleValue("latitude"));
		         	 activityPlace.setLongitude(jsonObject.getDoubleValue("longitude"));
		         	 activityPlace.setName(jsonObject.getString("name"));
		         	 activityPlace.setMarkName(jsonObject.getString("markName"));
		             activityPlace.setType(ActivityPlace.TYPE_DESTINATION);
		         	 activityPlaces.add(activityPlace);
		           }
	    	  }

	      }
    }
    catch( JSONException e ) {
    	log.error("app create Activity : change ActivityPlace to Json throw Exception ",e);
	    return Collections.emptyList();
    }
	  return activityPlaces;
  }
    
    /**
     * 活动表单验证
     *
     * @param activity
     * @param resp
     * @
     */
    private String checkActivity(Activity activity) {
        if (StringUtils.isBlank(activity.getPicUrl()) || (activity.getPicUrl().equals(defalutImg))) {
        	return "请上传活动封面图";
        } else if (StringUtils.isBlank(activity.getTitle())) {
            return "请输入活动名称";
        } else if (StringUtils.length(activity.getTitle()) > Activity.TITLE_SIZE) {
            return "最多30个字";
        }else if (activity.getBeginDate() == null) {
            return "请选择活动开始时间";
        } else if (activity.getEndDate() == null) {
            return "请选择活动结束时间";
        } else if (activity.getSignupDate() == null) {
             return "请选择活动报名截止时间";
        } else if (activity.getJoinNum() < 0) {
             return "活动费用不能小于0";
        } else if(activity.getType() == 0){
            return "活动类型不能为空";
        }
        return "";
    }
    
     
    /**
     * 判断用户是否已报名
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value="/1.0/activity/hasApplyed.do",method= RequestMethod.GET)
    public void hasApplyed(HttpServletRequest request, HttpServletResponse response){
    	WebUtils.setEncoding4App(request, response);
    	long userId = AppControllerStatic.paramUserId(request);
    	long activityId = AppControllerStatic.paramActivityId(request);
    	String callback = AppControllerStatic.paramCallback(request);
    	JSONObject json = new JSONObject();
    	//参数检查
    	User user =userService.findUser(userId);
    	 //判断用户是存在
        if (user == null || user.getUid() <= 0) {
            AppControllerStatic.printErrorMsg(response, "该用户不存在", json, callback, AppControllerStatic.V1_VERSION);
            return;
        }
        ClubMember clubMember = memberService.findClubMemberByUserId(userId);
        if (clubMember == null) {
            AppControllerStatic.printErrorMsg(response, "该用户还没加入车友会", json, callback, AppControllerStatic.V1_VERSION);
            return;
        }
        //判断活动是否存在
        Activity activity = activityService.findById(activityId);
        if(activity == null){
        	 AppControllerStatic.printErrorMsg(response, "该活动不存在", json, callback, AppControllerStatic.V1_VERSION);
             return;
        }
        
        ActivityMember activityMember = activityService.getApplyByUidAid(clubMember.getId(), activityId, ActivityMember.STATUS_OTHER);
        json.put("isSignup",  activityMember != null ? activityMember.getStatus() : STATUS_NO_SIGNUP) ;
        json.put("activityId", activityId);
    	json.put("userId", userId);
    	if(json.getIntValue("isSignup") == ActivityMember.STATUS_APPLY){
    		 json.put("isSingupMsg", "审核中");
    	}else if(json.getIntValue("isSignup") == ActivityMember.STATUS_PASS){
    		 json.put("isSingupMsg", "报名成功");
    	}else{
   	    	 json.put("isSingupMsg", "未报名");
   	    }
        AppControllerStatic.printSuccessMsg(response, json, callback, AppControllerStatic.V1_VERSION);
    }
    
    /**
     * 2.1.2 批量获取用户活动的报名情况
     * 1.3.5 判断用户是否已报名2.0 版本（批量处理）
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value="/2.0/activity/hasApplyed.do",method= RequestMethod.GET)
    public void getActivitysApply(HttpServletRequest request, HttpServletResponse response){
    	WebUtils.setEncoding4App(request, response);
    	String callback = AppControllerStatic.paramCallback(request);
    	String activityIds = WebUtils.param(request, "activityIds", "");
    	long userId = AppControllerStatic.paramUserId(request);
    	JSONObject jsonObject = new JSONObject();
    	String[] activityIdArray  = activityIds.split(",");
    	//参数检查
    	if(activityIdArray.length > BATCH_MAX_SIZE){
    		AppControllerStatic.printErrorMsg(response, "批量处理超出最大范围："+BATCH_MAX_SIZE ,jsonObject, null, AppControllerStatic.V2_VERSION_LATEST);
    		return;
    	}
    	if(activityIdArray==null){
    		AppControllerStatic.printErrorMsg(response, "参数有误" ,jsonObject, null, AppControllerStatic.V2_VERSION_LATEST);
    		return;
    	}
    	
    	User user =userService.findUser(userId);
    	 //判断用户是存在
        if (user == null || user.getUid() <= 0) {
            AppControllerStatic.printErrorMsg(response, "该用户不存在", jsonObject, callback, AppControllerStatic.V2_VERSION_LATEST);
            return;
        }
        ClubMember clubMember = memberService.findClubMemberByUserId(userId);
        if (clubMember == null) {
            AppControllerStatic.printErrorMsg(response, "该用户还没加入车友会", jsonObject, callback, AppControllerStatic.V2_VERSION_LATEST);
            return;
        }
    	JSONArray dataArray = new JSONArray();
    	for(String actString : activityIdArray){
    		JSONObject dataObject = new JSONObject();
    		long activityId = NumberUtils.toLong(actString, 0);
    		if(activityId>0){
    			Activity activity = activityService.findById(activityId);
	   			 if(activity == null){
	   				 continue;
	   			 }
	   			 ActivityMember activityMember = activityService.getApplyByUidAid(clubMember.getId(), activityId, ActivityMember.STATUS_OTHER);
	   			 dataObject.put("isSignup",  activityMember != null ? activityMember.getStatus() : STATUS_NO_SIGNUP) ;
	   			 dataObject.put("activityId", activityId);
	   			 dataObject.put("userId", userId);
	   	    	 if(dataObject.getIntValue("isSignup") == ActivityMember.STATUS_APPLY){
	   	    		dataObject.put("isSingupMsg", "审核中");
	   	    	 }else if(dataObject.getIntValue("isSignup") == ActivityMember.STATUS_PASS){
	   	    		dataObject.put("isSingupMsg", "报名成功");
	   	    	 }else{
	   	    		dataObject.put("isSingupMsg", "未报名");
	   	   	     }
	   	    	dataArray.add(dataObject); 
    		}
    		
    	}
    	jsonObject.put("data", dataArray );
    	 AppControllerStatic.printSuccessMsg(response, jsonObject, callback, AppControllerStatic.V2_VERSION_LATEST);
    }
    
    /**
     * 获取活动状态提示
     * 
   	 * 101：报名结束（人数限制） 102：活动结束  103：活动进行中 
   	 * 104：报名结束（时间限制） 105：火热报名  
   	 *         
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value = "/1.0/activity/getActivityStatus.do")
    public void getActivityStatus(HttpServletRequest request, HttpServletResponse response) {
    	WebUtils.setEncoding4App(request, response);
    	String callback = AppControllerStatic.paramCallback(request);
        long activityId = AppControllerStatic.paramActivityId(request);
        
        JSONObject jsonObject = new JSONObject();
        
        //判断活动是否存在
        Activity activity = activityService.findById(activityId);
        if(activity == null) {
        	AppControllerStatic.printErrorMsg(response, "此活动不存在", jsonObject, callback, AppControllerStatic.V1_VERSION);
        	return;
        }
        
        long nowDate = DateUtils.getNow().getTime();//系统时间
        long endDate = activity.getEndDate().getTime();//活动结束时间
        long signupDate = activity.getSignupDate().getTime();//报名截止时间
        int maxJoin = activity.getMaxJoin();//最大可报名人数
        int joinNum = activity.getJoinNum();//已成功报名人数
        
        jsonObject.put("activityId", activityId);
        
        String statusMsg = "";
        int statusCode = 0;
        //人数限制
        if(maxJoin != 0 && joinNum >= maxJoin) {
        	statusMsg = "报名结束";
        	statusCode = 101;
        }
        //活动结束时间限制
        else if(nowDate > endDate) {
        	statusMsg = "活动结束";
        	statusCode = 102;
        }
        //活动报名时间限制
        else if(nowDate > signupDate) {
        	statusMsg = "报名结束";
        	statusCode = 104;
        }
        //活动火热报名中
        else if(nowDate < signupDate) {
        	statusMsg = "我要报名";
        	statusCode = 105;
        }
        else {
        	statusMsg = "活动状态不明确";
        }
        
        jsonObject.put("statusMsg", statusMsg);
        jsonObject.put("statusCode", statusCode);
        
        AppControllerStatic.printSuccessMsg(response, jsonObject, callback, AppControllerStatic.V1_VERSION);
        
    }
    
    /**
     * 2.1.1 批量获取活动列表的状态提示
     * 1.3.4 获取活动状态提示2.0 版本，批量返回数据
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value = "/2.0/activity/getActivityStatus.do")
    public void getActivitysStatus(HttpServletRequest request, HttpServletResponse response){
    	WebUtils.setEncoding4App(request, response);
    	String callback = AppControllerStatic.paramCallback(request);
    	String activityIds = WebUtils.param(request, "activityIds", "");
    	JSONObject jsonObject = new JSONObject();
    	String[] activityIdArray  = activityIds.split(",");
    	if(activityIdArray.length > BATCH_MAX_SIZE){
    		AppControllerStatic.printErrorMsg(response, "批量处理超出最大范围："+BATCH_MAX_SIZE ,jsonObject, null, AppControllerStatic.V2_VERSION_LATEST);
    		return;
    	}
    	if(activityIdArray==null){
    		AppControllerStatic.printErrorMsg(response, "参数有误" ,jsonObject, null, AppControllerStatic.V2_VERSION_LATEST);
    		return;
    	}
    	JSONArray dataArray = new JSONArray();
    	long nowDate = DateUtils.getNow().getTime();//系统时间
    	for(String actString : activityIdArray){
    		JSONObject dataObject = new JSONObject();
    		long activityId = NumberUtils.toLong(actString, 0);
    		if(activityId>0){
    			Activity activity = activityService.findById(activityId);
    			 if(activity == null){
    				 continue;
    			 }
    			 long endDate = activity.getEndDate().getTime();//活动结束时间
    		     long signupDate = activity.getSignupDate().getTime();//报名截止时间
    		     int maxJoin = activity.getMaxJoin();//最大可报名人数
    		     int joinNum = activity.getJoinNum();//已成功报名人数
    		     dataObject.put("activityId", activityId);
    		     String statusMsg = "";
    		        int statusCode = 0;
    		        //人数限制
    		        if(maxJoin != 0 && joinNum >= maxJoin) {
    		        	statusMsg = "报名结束";
    		        	statusCode = 101;
    		        }
    		        //活动结束时间限制
    		        else if(nowDate > endDate) {
    		        	statusMsg = "活动结束";
    		        	statusCode = 102;
    		        }
    		        //活动报名时间限制
    		        else if(nowDate > signupDate) {
    		        	statusMsg = "报名结束";
    		        	statusCode = 104;
    		        }
    		        //活动火热报名中
    		        else if(nowDate < signupDate) {
    		        	statusMsg = "我要报名";
    		        	statusCode = 105;
    		        }
    		        else {
    		        	statusMsg = "活动状态不明确";
    		        }
    		        dataObject.put("statusMsg", statusMsg);
    		        dataObject.put("statusCode", statusCode);
    		        dataArray.add(dataObject);
    		}
    		
    	}
    	jsonObject.put("data", dataArray );
    	AppControllerStatic.printSuccessMsg(response, jsonObject, callback, AppControllerStatic.V2_VERSION_LATEST);
    }
      
    /**
     * 1.3.2 活动详情
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value = "/1.0/activity/getActivityDetail.do", method = RequestMethod.GET)
    public void getActivityDetail(HttpServletRequest request, HttpServletResponse response){
    	WebUtils.setEncoding4App(request, response);
    	long activityId = AppControllerStatic.paramActivityId(request);
    	String callback = AppControllerStatic.paramCallback(request);
    	int xssEncode = AppControllerStatic.paramXssEncode(request);
    	Activity activity = activityService.findById(activityId);
    	JSONObject jsonObject = new JSONObject();
    	if(activity==null){
    		AppControllerStatic.printErrorMsg(response, "该活动不存在", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
            return;
    	}
    	//设置返回值
    	jsonObject.put("clubId",activity.getClubId());
    	jsonObject.put("activityId", activityId);
    	jsonObject.put("title", xssEncode == 0 ? activity.getTitle() : EncodeUtils.encodeForHTMLFilterNull(activity.getTitle()));
    	jsonObject.put("activityImgUrl", xssEncode == 0 ? activity.getUrl600x400() : EncodeUtils.encodeForHTMLFilterNull(activity.getUrl600x400()));
    	int type = activity.getType();
    	jsonObject.put("activityType", type);
    	long createBy = activity.getCreateBy();
    	jsonObject.put("createBy",createBy);
    	User user = userService.findUser(createBy);
    	if(user!=null){
    		jsonObject.put("userName",xssEncode == 0 ? user.getUsername() : EncodeUtils.encodeForHTMLFilterNull(user.getUsername()));
    		jsonObject.put("authorTel",xssEncode == 0 ? user.getPhone() : EncodeUtils.encodeForHTMLFilterNull(user.getPhone()));
    	}
    	jsonObject.put("nickName",userService.getNickNameByUserId(createBy));
    	
    	jsonObject.put("createAt",activity.getCreateAt().getTime());
    	jsonObject.put("beginDate",activity.getBeginDate().getTime());
    	jsonObject.put("endDate",activity.getEndDate().getTime());
    	jsonObject.put("signupDate",activity.getSignupDate().getTime());
    	jsonObject.put("money",activity.getMoney());
    	String fullContent = activityService.getTotalActivityTxt(activityId);
    	jsonObject.put("content",xssEncode == 0 ? fullContent : EncodeUtils.encodeForHTMLFilterNull(fullContent));
    	jsonObject.put("limitCount",activity.getMaxJoin());
    	List<ActivityPic> listPics = activityPicService.listPicsByActivity(activity, ActivityPic.ORDER_ASC);
    	JSONArray picArray = new JSONArray();
    	for(ActivityPic pic : listPics){
    		JSONObject picObject =  xssEncode == 0 ? pic.toJson() : pic.toJsonEncodeHTML();
    		picArray.add(picObject);
    	}
    	jsonObject.put("contentImages", picArray);

    	List<ActivityPlace> destinations = activityPlaceService.listPlaceByActivityAndType( activity,ActivityPlace.TYPE_DESTINATION);
    	JSONArray destinationArray = new JSONArray();
    	for( int i = 0; i < destinations.size(); i++ ) {
    		ActivityPlace destinationPlace = destinations.get(i);
    		JSONObject destinationObject = xssEncode == 0 ? destinationPlace.toJson() : destinationPlace.toJsonEncodeHTML();
    		destinationArray.add(destinationObject);
        }
    	List<ActivityPlace> gathers = activityPlaceService.listPlaceByActivityAndType(activity,ActivityPlace.TYPE_GATHERING);
    	if(gathers!=null && gathers.size()>0){
    		ActivityPlace gatherPlace = gathers.get(0);
    		JSONObject gatherObject = xssEncode == 0 ? gatherPlace.toJson() : gatherPlace.toJsonEncodeHTML();
    		jsonObject.put("gatherPlace", gatherObject);
    	}
    	
    	String activityPlace = "";
    	if(type == Activity.TYPE_OTHER) {
    		activityPlace = "线上";
    	} else {
    		activityPlace = activity.getCityName() == null ? "" : activity.getCityName();
    	}
    	jsonObject.put("activityPlace", xssEncode == 0 ? activityPlace : EncodeUtils.encodeForHTMLFilterNull(activityPlace));
    	jsonObject.put("destinationPlaces", destinationArray);
    	jsonObject.put("applyCount", activity.getJoinNum());
    	AppControllerStatic.printSuccessMsg(response, jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
    }
    
    /**
     * 删除活动操作，修改活动状态为删除
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value = "/1.0/activity/delActivity.do", method = RequestMethod.POST)
    public void delActivity(HttpServletRequest request, HttpServletResponse response) {
    	WebUtils.setEncoding4App(request, response);
    	String callback = AppControllerStatic.paramCallback(request);
        long activityId = AppControllerStatic.paramActivityId(request);
        
        JSONObject jsonObject = new JSONObject();
        
        //判断用户是否登录
        User user = userAuth.getUser(request, response);
        if(user == null || user.getUid() <= 0) {
        	AppControllerStatic.printErrorMsg(response, "用户未登录", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        
        //判断活动是否存在
        Activity activity = activityService.findById(activityId);
        if(activity == null) {
        	AppControllerStatic.printErrorMsg(response, "该活动不存在", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        
        //活动创建者ID
        long createBy = activity.getCreateBy();
        
        //判断登录用户是否有删除操作权限--管理员，或者活动发布者
        boolean hasDeleteRole = false;
        long clubId = activity.getClubId();
        
        //获得车友会信息
        Club club = clubService.getValidClub(clubId);
        if(club == null) {
        	AppControllerStatic.printErrorMsg(response, "该车友会不存在", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        
        long userId = user.getUid();
        if(userId != createBy) {//判断是否为车友会管理者
        	hasDeleteRole = memberService.isClubNormalAdmin(userId, clubId);
        } else {//活动发布者
        	hasDeleteRole = true;
        }
        if(!hasDeleteRole) {
        	AppControllerStatic.printErrorMsg(response, "没有该操作权限", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        } 
        
        List<ActivityMember> membersPass = activityService.listMemberByActivitiId(activityId, 1); //已审
        List<ActivityMember> members = activityService.listMemberByActivitiId(activityId, 0);  //未审
        //删除活动
        int deleteResult = activityService.removeActivity(activityId);
        //删除车友会活动动态
        if(deleteResult > 0) {
            DynaInfo dynaInfo = dynaService.findDynaByTypeTargetId(DynaInfo.TYPE_ACTIVITY, activityId, activity.getCreateAt());
            if(dynaInfo != null) {
                    dynaService.deleteClubDyna(activity.getClubId(), dynaInfo.getDynaInfoId());
                    dynaService.deleteUserDyna(dynaInfo.getCreateBy(), dynaInfo.getDynaInfoId());
                    dynaIndexService.deleteDynaIndex(dynaInfo.getDynaInfoId()); //删除动态索引表
            }
                
            // 用户已报名还未审核的活动被删除，通知用户
            for (ActivityMember u : members) {
            	//不发给创活动建者自己
            	if(userId == createBy) {
            		continue;
            	}
                 messageService.send(u.getUser(), MessageService.DELETE_ACTIVITY_JOINED,
                            messageService.assembleUserUrl(user.getUid(), user.getNickname()));
            }
            // 用户已报名参加且通过的活动被删除，通知用户
            for (ActivityMember u : membersPass) {
            	//不发给创活动建者自己
            	if(userId == createBy) {
            		continue;
            	}
                 messageService.send(u.getUser(), MessageService.DELETE_ACTIVITY_JOINED,
                            messageService.assembleUserUrl(user.getUid(), user.getNickname()));
            }
            
            //是管理者也是活动发起人，删除活动时不用系统消息
            if(memberService.isClubNormalAdmin(userId, clubId) && userId != createBy){ 
                //用户发起的活动被删除，通知用户
                User receiver = userService.findUser(activity.getCreateBy());
                 messageService.send(receiver, MessageService.DELETE_ACTIVITY_CREATED,
                        messageService.assembleActivityUrl(club.getClubUrl(), activityId, activity.getTitle()), messageService.assembleUserUrl(user.getUid(), user.getNickname()));
            }
                
        }
    	AppControllerStatic.printSuccessMsg(response, jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
    }
    
    /**
     * 1.3.8 活动审核
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value = "/1.0/activity/auditApply.do", method = RequestMethod.POST)
    public void auditApply(HttpServletRequest request, HttpServletResponse response){
    	WebUtils.setEncoding4App(request, response);
    	int action = WebUtils.paramInt(request, "action", 0);
    	long uid = AppControllerStatic.paramUserId(request);
    	long activityId = AppControllerStatic.paramActivityId(request);
    	String callback = AppControllerStatic.paramCallback(request);
    	JSONObject jsonObject = new JSONObject();
    	//判断指令操作
    	if (action != ActivityMember.STATUS_PASS && action != ActivityMember.STATUS_DELETE){
    		AppControllerStatic.printErrorMsg(response, "指令错误", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
    	}
    	//判断用户是否登录
        User user = userAuth.getUser(request, response);
        
        if(user == null || user.getUid() <= 0) {
        	AppControllerStatic.printErrorMsg(response, "用户未登录", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        //判断活动是否存在
        Activity activity = activityService.findById(activityId);
        if(activity == null) {
        	AppControllerStatic.printErrorMsg(response, "该活动不存在", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        
        //判断登录用户是否活动发布者
        long userId = user.getUid();
        if(userId != activity.getCreateBy()){
        	AppControllerStatic.printErrorMsg(response, "只有活动发布者才有审核权限", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        
        //是否为本车友会的活动
        ClubMember clubMember = memberService.findClubMemberByUserId(userId);
        if(activity.getClubId() != clubMember.getClubId()) {
        	AppControllerStatic.printErrorMsg(response, "只可以操作本车友会的活动", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        
        //被审核人的车友会信息
        ClubMember clubMemberTarget = memberService.findMember(uid, activity.getClubId());
        ActivityMember member = activityService.getApplyByUidAid(clubMemberTarget.getId(), activityId, ActivityMember.STATUS_APPLY);
        
        if (member == null){
        	AppControllerStatic.printErrorMsg(response, "该申请已被处理", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        if (action == ActivityMember.STATUS_PASS && (activity.getMaxJoin() > 0 && activity.getMaxJoin() < (activity.getJoinNum() + member.getJoinNum()))) {
        	AppControllerStatic.printErrorMsg(response, "审核失败，人数超过上限", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        boolean result =activityService.editApplyBy(action, member, activity.getClubId());  //审核操作
        if(!result){
        	String msg = "审核失败";
        	if(action == ActivityMember.STATUS_DELETE){
        		msg = "拒绝失败";
        	}
        	AppControllerStatic.printErrorMsg(response, msg, jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        Club club = clubService.getValidClub(activity.getClubId());
        
        if (action == ActivityMember.STATUS_DELETE) {
            User createUser = userService.findUser(activity.getCreateBy());
            
            //给申请人发送拒绝消息
            messageService.send(userService.findUser(clubMemberTarget.getUid()), MessageService.ACT_APPLY_FALSE, 
                    messageService.assembleUserUrl(createUser.getUid(), createUser.getNickname()));
        } else {
            //给申请人发送审核通过消息
            messageService.send(userService.findUser(clubMemberTarget.getUid()), MessageService.ACT_APPLY_PASS, 
                    messageService.assembleActivityUrl(club.getClubUrl(), activityId, activity.getTitle()));
        }
        
        AppControllerStatic.printSuccessMsg(response, jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
    }
    
    /**
     * 活动报名列表（审核中）
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value="/1.0/activity/getApplyingList.do",method= RequestMethod.GET)
    public void getApplyingList(HttpServletRequest request, HttpServletResponse response){
    	WebUtils.setEncoding4App(request, response);
    	long activityId = AppControllerStatic.paramActivityId(request);
    	String callback = AppControllerStatic.paramCallback(request);
    	int xssEncode = AppControllerStatic.paramXssEncode(request);
    	JSONObject json = new JSONObject();
    	
        //判断活动是否存在
        Activity activity = activityService.findById(activityId);
        if(activity == null){
        	 AppControllerStatic.printErrorMsg(response, "该活动不存在", json, callback, AppControllerStatic.V1_VERSION);
             return;
        }
        
        List<ActivityMember> activityMembers = activityService.listActivityAuditMembers(activityId);
        if(activityMembers == null || activityMembers.isEmpty()){
        	 AppControllerStatic.printErrorMsg(response, "该活动暂时还没有待审核的报名人", json, callback, AppControllerStatic.V1_VERSION);
             return;
        }
        
        json.put("activityId", activityId);
        json.put("total", activityMembers.size());
        JSONArray jsonArray = new JSONArray();        
        for(ActivityMember activityMember : activityMembers){
        	JSONObject jsonObject = xssEncode == 0 ? activityMember.toJson() : activityMember.toJsonEncodeHTML();
        	ClubMember member = memberService.findMember(activityMember.getUserId());
        	jsonObject.put("userId", member == null ? "" : member.getUid());
        	jsonArray.add(jsonObject);
        }
        json.put("apply", jsonArray);
        AppControllerStatic.printSuccessMsg(response, json, callback, AppControllerStatic.V1_VERSION);
    }
    
    /**
     * 2.1.3 批量获取活动列表的报名列表（审核中）
     * 1.3.9 活动报名列表2.0版本（批量处理）
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value="/2.0/activity/getApplyingList.do",method= RequestMethod.GET)
    public void getActivitysApplyingList(HttpServletRequest request, HttpServletResponse response){
    	WebUtils.setEncoding4App(request, response);
    	String callback = AppControllerStatic.paramCallback(request);
    	String activityIds = WebUtils.param(request, "activityIds", "");
    	long clubId = AppControllerStatic.paramClubId(request);
    	int xssEncode = AppControllerStatic.paramXssEncode(request);
    	JSONObject jsonObject = new JSONObject();
    	String[] activityIdArray  = activityIds.split(",");
    	//参数检查
    	if(activityIdArray.length > BATCH_MAX_SIZE){
    		AppControllerStatic.printErrorMsg(response, "批量处理超出最大范围："+BATCH_MAX_SIZE ,jsonObject, null, AppControllerStatic.V2_VERSION_LATEST);
    		return;
    	}
    	if(activityIdArray==null){
    		AppControllerStatic.printErrorMsg(response, "参数有误" ,jsonObject, null, AppControllerStatic.V2_VERSION_LATEST);
    		return;
    	}
    	Club club = clubService.getValidClub( clubId );
    	if(club==null){
    		AppControllerStatic.printErrorMsg(response, "车友会不存在", null , null, AppControllerStatic.V2_VERSION_LATEST);
 	        return;
    	}
        
    	JSONArray dataArray = new JSONArray();
    	for(String actString : activityIdArray){
    		JSONObject dataObject = new JSONObject();
    		long activityId = NumberUtils.toLong(actString, 0);
    		if(activityId>0){
    			Activity activity = activityService.findById(activityId);
	   			 if(activity == null){
	   				 continue;
	   			 }
	   			List<ActivityMember> activityMembers = activityService.listActivityAuditMembers(activityId);
	   			dataObject.put("activityId", activityId);
	   			JSONArray jsonArray = new JSONArray(); 
	   	        if(activityMembers == null || activityMembers.isEmpty()){
	   	        	dataObject.put("total", 0);
	   	        }else{
	   	        	dataObject.put("total", activityMembers.size());
		   	        for(ActivityMember activityMember : activityMembers){
		   	        	JSONObject applyObject = xssEncode == 0 ? activityMember.toJson() : activityMember.toJsonEncodeHTML();
		   	        	ClubMember member = memberService.findMember(activityMember.getUserId());
		   	        	applyObject.put("userId", member == null ? "" : member.getUid());
		   	        	jsonArray.add(applyObject);
		   	        }
	   	        }
	   	     dataArray.add(dataObject);
    		}
    	}
    	jsonObject.put("data", dataArray );
    	AppControllerStatic.printSuccessMsg(response, jsonObject, callback, AppControllerStatic.V2_VERSION_LATEST);
    }
    
    /**
     * 活动报名列表（审核通过）
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value="/1.0/activity/getApplyedList.do",method= RequestMethod.GET)
    public void getApplyedList(HttpServletRequest request, HttpServletResponse response){
    	WebUtils.setEncoding4App(request, response);
    	long activityId = AppControllerStatic.paramActivityId(request);
    	String callback = AppControllerStatic.paramCallback(request);
    	int xssEncode = AppControllerStatic.paramXssEncode(request);
    	int pageSize = AppControllerStatic.paramPageSize(request);
        int pageNo = AppControllerStatic.paramPageNo(request);
        
    	JSONObject json = new JSONObject();

        //判断活动是否存在
        Activity activity = activityService.findById(activityId);
        if(activity == null){
        	 AppControllerStatic.printErrorMsg(response, "该活动不存在", json, callback, AppControllerStatic.V1_VERSION);
             return;
        }

        Pager<ActivityMember> pager = activityService.pageForApplyList(activityId, ActivityMember.STATUS_PASS, pageNo, pageSize);
    	if(pager.getResultList()!= null && !pager.getResultList().isEmpty()){
            JSONArray jsonArray = new JSONArray();  
	        for(ActivityMember activityMember : pager.getResultList()){
	        	JSONObject jsonObject = xssEncode == 0 ? activityMember.toJson() : activityMember.toJsonEncodeHTML();
	        	ClubMember member = memberService.findMember(activityMember.getUserId());
	        	jsonObject.put("userId", member == null ? "" : member.getUid());
	        	jsonArray.add(jsonObject);
	    	}
	        json.put("activityId", activityId);
   			json.put("data", jsonArray);
			json.put("total", pager.getTotal());
			json.put("pageNo", pager.getPageNo());
			json.put("pageSize", pager.getPageSize());
			json.put("pageCount", pager.getPageCount());
			AppControllerStatic.printSuccessMsgPager(response, json, callback, pager, AppControllerStatic.V1_VERSION);
			return;
    	}
    	AppControllerStatic.printErrorMsgPager(response, "该活动暂时没有报名审核通过的人", json, callback, AppControllerStatic.V1_VERSION);
    }
    
    /**
     * 2.1.4 批量获取活动列表的报名列表（审核通过）
     * 1.3.10 活动报名列表 2.0 版本（批量处理）
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value="/2.0/activity/getApplyedList.do",method= RequestMethod.GET)
    public void getActivitysApplyedList(HttpServletRequest request, HttpServletResponse response){
    	WebUtils.setEncoding4App(request, response);
    	String callback = AppControllerStatic.paramCallback(request);
    	long clubId = AppControllerStatic.paramClubId(request);
    	String activityIds = WebUtils.param(request, "activityIds", "");
    	int xssEncode = AppControllerStatic.paramXssEncode(request);
    	JSONObject jsonObject = new JSONObject();
    	String[] activityIdArray  = activityIds.split(",");
    	int pageSize = AppControllerStatic.paramPageSize(request);
        int pageNo = AppControllerStatic.paramPageNo(request);
        
    	//参数检查
    	if(activityIdArray.length > BATCH_MAX_SIZE){
    		AppControllerStatic.printErrorMsg(response, "批量处理超出最大范围："+BATCH_MAX_SIZE ,jsonObject, null, AppControllerStatic.V2_VERSION_LATEST);
    		return;
    	}
    	if(activityIdArray==null){
    		AppControllerStatic.printErrorMsg(response, "参数有误" ,jsonObject, null, AppControllerStatic.V2_VERSION_LATEST);
    		return;
    	}
    	Club club = clubService.getValidClub( clubId );
    	if(club==null){
    		AppControllerStatic.printErrorMsg(response, "车友会不存在", null , null, AppControllerStatic.V2_VERSION_LATEST);
 	        return;
    	}
        JSONArray dataArray = new JSONArray();
    	for(String actString : activityIdArray){
    		JSONObject dataObject = new JSONObject();
    		long activityId = NumberUtils.toLong(actString, 0);
    		if(activityId>0){
    			Activity activity = activityService.findById(activityId);
	   			if(activity == null){
	   				 continue;
	   			}
	   			dataObject.put("activityId", activityId);
	   	        Pager<ActivityMember> pager = activityService.pageForApplyList(activityId, ActivityMember.STATUS_PASS, pageNo, pageSize);
	   	    	if(pager.getResultList()!= null && !pager.getResultList().isEmpty()){
	   	            JSONArray applyedArray = new JSONArray();  
	   		        for(ActivityMember activityMember : pager.getResultList()){
	   		        	JSONObject applyedObject = xssEncode == 0 ? activityMember.toJson() : activityMember.toJsonEncodeHTML();
	   		        	ClubMember member = memberService.findMember(activityMember.getUserId());
	   		        	applyedObject.put("userId", member == null ? "" : member.getUid());
	   		        	applyedArray.add(applyedObject);
	   		    	}
	   		        
	   		        dataObject.put("applyed", applyedArray);
	   		        dataObject.put("total", pager.getTotal());
	   		        dataObject.put("pageNo", pager.getPageNo());
	   		        dataObject.put("pageSize", pager.getPageSize());
	   		        dataObject.put("pageCount", pager.getPageCount());
	   				
	   	    	}else{	//没有报名的
	   	    		dataObject.put("total",0);
	   	    	}
	   			
	   	    	dataArray.add(dataObject);
    		}
    		
    	}
    	jsonObject.put("data", dataArray );
    	AppControllerStatic.printSuccessMsg(response, jsonObject, callback, AppControllerStatic.V2_VERSION_LATEST);
    	
    }
    
    /**
     * 活动报名
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value = "/1.0/activity/applyActivity.do", method = RequestMethod.POST)
    public void applyActivity(HttpServletRequest request, HttpServletResponse response) {
    	WebUtils.setEncoding4App(request, response);
    	String callback = AppControllerStatic.paramCallback(request);
        long activityId = AppControllerStatic.paramActivityId(request);
        
        JSONObject jsonObject = new JSONObject();
        
        //判断用户是否登录
        User user = userAuth.getUser(request, response);
        if(user == null || user.getUid() <= 0) {
        	AppControllerStatic.printErrorMsg(response, "用户未登录", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        
        //判断活动是否存在
        Activity activity = activityService.findById(activityId);
        if(activity == null) {
        	AppControllerStatic.printErrorMsg(response, "该活动不存在", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        
        //报名人数已满
        if (activity.getMaxJoin() != 0 && activity.getJoinNum() >= activity.getMaxJoin()) {
        	AppControllerStatic.printErrorMsg(response, "报名人数已满，请联系管理员", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        
        //报名时间结束
        long now = System.currentTimeMillis();
        if (now > activity.getSignupDate().getTime()) {
        	AppControllerStatic.printErrorMsg(response, "报名结束", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        
        //用户车友会身份验证
        ClubMember clubMember = memberService.findMember(user.getUid(), activity.getClubId());
        if (clubMember == null) {
        	AppControllerStatic.printErrorMsg(response, "只有该车友会会员才能报名哦", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        
        //判断是否报名审核中
        int count = activityService.countActivityMemberByActIdUserId(activityId, clubMember.getId());
        if(count > 0) {
        	AppControllerStatic.printErrorMsg(response, "不能重复报名哦", jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        
        //设置活动报名申请对象
        ActivityMember member = this.convertoAcMember(activityId, clubMember.getId(), request);
        member.setNikename(user.getNickname());
        //申请表单检验
        String result = this.inifcheckAcMember(member);
        if (StringUtils.isNotEmpty(result)) {
        	AppControllerStatic.printErrorMsg(response, result, jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        	return;
        }
        
        //创建活动申请
        long i = activityService.createActityMember(member);
        if (i > 0) {
            activityService.refshActivityJoinNum(activityId, activity.getClubId());
            //给没看到创建者发送审核消息
            Club club = clubService.getValidClub(activity.getClubId());
            if (club != null) {
                String activityUrl = messageService.assembleClubUrl(club.getClubUrl() + "/activity/a" + activityId, activity.getTitle());
                User createUser = userService.findUser(activity.getCreateBy());
                if(createUser != null) {
                	messageService.send(createUser, MessageService.ACTIVITY_APPLY, activityUrl, member.getName());
                }
            }
            //操作成功
            AppControllerStatic.printSuccessMsg(response, jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        } else {
        	//操作失败
            AppControllerStatic.printErrorMsg(response, jsonObject, callback, AppControllerStatic.V1_VERSION_LATEST);
        }
    }
    
    /**
     * 设置活动报名申请对象
     * @param activityId
     * @param memberId
     * @param req
     * @return
     */
    private ActivityMember convertoAcMember(long activityId, long memberId, HttpServletRequest request) {
        ActivityMember activityMember = new ActivityMember();
        activityMember.setActivityId(activityId);
        activityMember.setUserId(memberId);
        activityMember.setName(WebUtils.param(request, "name", "").trim());
        activityMember.setPhone(WebUtils.param(request, "phone", "").trim());
        activityMember.setJoinNum(WebUtils.paramInt(request, "joinNum", 0));
        activityMember.setLincensePlate(WebUtils.param(request, "lincensePlate", "").trim());
        activityMember.setDescript(WebUtils.param(request, "descript", "").trim());
        activityMember.setCreateAt(DateUtils.getNow());
        activityMember.setStatus(ActivityMember.STATUS_APPLY);
        activityMember.setIsDriving(WebUtils.paramInt(request, "isDriving", ActivityMember.ISDRIVING_YES));
        return activityMember;
    }
    
    /**
     * 接口验证活动报名字段
     *
     * @param member
     * @return
     */
    private String inifcheckAcMember(ActivityMember member) {
    	String message = "";
        if (StringUtils.isBlank(member.getName())) {
            message = "请输入真实姓名";
        } else if (member.getName().length() > 20) {
            message = "姓名长度不能超过20";
        } else if (StringUtils.isBlank(member.getPhone())) {
            message = "请输入联系电话";
        } else if (member.getPhone().length() > 20) {
            message = "电话长度不能超过20";
        } else if (member.getJoinNum() < 1) {
            message = "请输入正确的人数";
        } else if (member.getLincensePlate().length() > 20) {
            message = "车牌长度不能超过20";
        } else if (member.getDescript().length() > 255) {
            message = "备注长度不能超过255";
        } else if (member.getIsDriving() != ActivityMember.ISDRIVING_NO && member.getIsDriving() != ActivityMember.ISDRIVING_YES ) {
            message = "是否自驾车类型错误";
        }
        return message;
    }
    
    /**
     * 判断活动是否生成过动态（旧数据没有评论功能）
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value="/1.0/activity/hasDynaByActivityId.do",method= RequestMethod.GET)
    public void hasDynaByActivityId(HttpServletRequest request, HttpServletResponse response){
    	WebUtils.setEncoding4App(request, response);
    	long activityId = AppControllerStatic.paramActivityId(request);
    	String callback = AppControllerStatic.paramCallback(request);
        
    	JSONObject json = new JSONObject();

        //判断活动是否存在
        Activity activity = activityService.findById(activityId);
        if(activity == null){
        	 AppControllerStatic.printErrorMsg(response, "该活动不存在", json, callback, AppControllerStatic.V1_VERSION_LATEST);
             return;
        }
        
        //判断是否有活动动态
        DynaInfo dynaInfo = activityService.getDynaById(activity);
        long dynaInfoId = 0;
        int replyCount = 0; //评论数
        if(dynaInfo != null){
                dynaInfoId = dynaInfo.getDynaInfoId();
                //动态回复数
                replyCount = dynaInfo.getPostCount();
       }
       
       json.put(AppControllerStatic.APP_API_PARA_ACTIVITYID, activityId);
       json.put("dynaInfoId", dynaInfoId);
       json.put("replyCount", replyCount);
       
       AppControllerStatic.printSuccessMsg(response, json, callback, AppControllerStatic.V1_VERSION_LATEST);
        
    }
    
    @ResponseBody
    @RequestMapping(value="/1.0/activity/cancelActivity.do",method= RequestMethod.POST)
    public void cancelActivity(HttpServletRequest request, HttpServletResponse response){
      //获取相关参数
        WebUtils.setEncoding4App(request, response);
        long activityId = AppControllerStatic.paramActivityId(request);
        JSONObject jsonObject  = new JSONObject();
        jsonObject.put(AppControllerStatic.APP_API_PARA_ACTIVITYID, activityId);
        
        if(activityId <= 0) {
            AppControllerStatic.printErrorMsg(response, "非法参数activityId", jsonObject, null, AppControllerStatic.V1_VERSION_LATEST);
            return;
        }
        Activity activity = activityService.findById(activityId);
        if(activity == null) {
            AppControllerStatic.printErrorMsg(response, "活动不存在", jsonObject, null, AppControllerStatic.V1_VERSION_LATEST);
            return;
        }
        
        //获取用户信息
        User user = userAuth.getUser(request, response);
        //判断用户是否登录
        if (user == null || user.getUid() <= 0) {
            AppControllerStatic.printErrorMsg(response, "用户未登录", jsonObject, null, AppControllerStatic.V1_VERSION_LATEST);
            return;
        }
        
        ClubMember member = memberService.findMember(user.getUid(), activity.getClubId());
        if(member == null) {
            AppControllerStatic.printErrorMsg(response, "操作失败，您已被管理员移出车友会" ,jsonObject, null, AppControllerStatic.V1_VERSION_LATEST);
            return;
        }
        
        if (activity.getSignupDate().before(new Date())) {
            AppControllerStatic.printErrorMsg(response, "报名时间已截止，不能取消报名" ,jsonObject, null, AppControllerStatic.V1_VERSION_LATEST);
            return;
        }
        
        long i = activityService.deleteActityMember(activityId, member.getId());
        if (i <= 0) {
            AppControllerStatic.printErrorMsg(response, "取消失败" ,jsonObject, null, AppControllerStatic.V1_VERSION_LATEST);
            return;
        }
        
        /*
        //获取车友会
        Club club = clubService.getClub(activity.getClubId());
        String clubUrl = "";
        if(club != null) {
        	clubUrl = club.getClubUrl();
        }
        //取消活动报名发消息给活动发布者
        User adminUser = userService.findUser(activity.getCreateBy());
        messageService.send(adminUser, MessageService.ACT_APPLY_CANCEL,
                messageService.assembleUserUrl(user.getUid(), user.getNickname()), 
                messageService.assembleActivityUrl(clubUrl, activityId, activity.getTitle()));
        */
        
        activityService.refshActivityJoinNum(activityId, activity.getClubId());//更新报名人数
        AppControllerStatic.printSuccessMsg(response, jsonObject, null, AppControllerStatic.V1_VERSION_LATEST);
    }
    

    /**
     * 活动封面尺寸
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value = "/1.0/activity/getCoverUpcComm.do", method = RequestMethod.GET)
    public void getCoverUpcComm(HttpServletRequest request, HttpServletResponse response) {
    	WebUtils.setEncoding4App(request, response);
    	JSONObject jsonObject = new JSONObject();
    	jsonObject.put("commands", AppControllerStatic.UPC_COMMAND_ACTIVITY_COVER);
    	AppControllerStatic.printSuccessMsg(response, jsonObject, null, AppControllerStatic.V1_VERSION_LATEST);
    	
    }
    /**
     * 活动内容尺寸
     * @param request
     * @param response
     */
    @ResponseBody
    @RequestMapping(value = "/1.0/activity/getContentUpcComm.do", method = RequestMethod.GET)
    public void getContentUpcComm(HttpServletRequest request, HttpServletResponse response) {
    	WebUtils.setEncoding4App(request, response);
    	JSONObject jsonObject = new JSONObject();
    	jsonObject.put("commands", AppControllerStatic.UPC_COMMAND_ACTIVITY_CONTENT);
    	AppControllerStatic.printSuccessMsg(response, jsonObject, null, AppControllerStatic.V1_VERSION_LATEST);
    	
    }

}
